// @ts-nocheck
/**
 * @Date: 2022-03-08 12:07:13
 * @LastEditors: sailornpg
 * @LastEditTime: 2022-03-14 10:07:23
 * @FilePath: \zhihuReal\model\usersMdl.js
 * @Description: 用户Schema
 */
const {
    Schema
} = require('../db/db')
const mongoose = require('../db/db')
const userSchema = mongoose.Schema({
    __v: {
        type: Number,
        select: false
    },
    //用户名
    userName: {
        type: String,
        required: true
    },
    //密码
    password: {
        type: String,
        required: true,
        //隐藏
        select: false
    },
    //头像
    avatar_url: {
        type: String
    },
    //性别
    gender: {
        type: String,
        enum: ['male', 'female', ],
        default: 'male',
        required: true
    },
    //描述
    headline: {
        type: String
    },
    //居住地
    locations: {
        type: [{
            type: Schema.Types.ObjectId,
            ref: 'Topic'
        }],
        select: false
    },
    //所在行业
    business: {
        type: Schema.Types.ObjectId,
        ref: 'Topic',
        select: false
    },
    //职业
    employments: {
        type: [{
            company: {
                type: Schema.Types.ObjectId,
                ref: 'Topic',
            },
            job: {
                type: Schema.Types.ObjectId,
                ref: 'Topic',
            }
        }],
        select: false
    },
    //教育
    educations: {
        type: [{
            //学校
            school: {
                type: Schema.Types.ObjectId,
                ref: 'Topic',
            },
            //专业
            majoy: {
                type: Schema.Types.ObjectId,
                ref: 'Topic',
            },
            //学历
            diploma: {
                type: Number,
                enum: [1, 2, 3, 4, 5]
            },
            //入学年份
            entrance_year: {
                type: Number
            },
            //毕业年份
            graduation_year: {
                type: Number
            },
        }],
        select: false
    },
    //关注
    following: {
        type: [{
            type: Schema.Types.ObjectId,
            ref: 'User'
        }],
        select: false
    },
    //关注话题
    followingTopics: {
        type: [{
            type: Schema.Types.ObjectId,
            ref: 'Topic'
        }],
        select: false
    },
    //关注问题
    followingQuestions: {
        type: [{
            type: Schema.Types.ObjectId,
            ref: 'Question'
        }],
        select: false
    },
    //赞过的答案
    likeAnswerList: {
        type: [{
            type: Schema.Types.ObjectId,
            ref: 'Answer'
        }],
        select: false
    },
    //踩过的答案列表
    unLikeAnswerList: {
        type: [{
            type: Schema.Types.ObjectId,
            ref: 'Answer'
        }],
        select: false
    },
    //收藏的答案列表
    collectionAnswerList: {
        type: [{
            type: Schema.Types.ObjectId,
            ref: 'Answer'
        }],
        select: false
    },
    //踩过的评论列表
    unLikeCommentList: {
        type: [{
            type: Schema.Types.ObjectId,
            ref: 'Comment'
        }],
        select: false
    },
    //收藏的评论列表
    collectionCommentList: {
        type: [{
            type: Schema.Types.ObjectId,
            ref: 'Comment'
        }],
        select: false
    },
    //赞过的答案
    likeCommentList: {
        type: [{
            type: Schema.Types.ObjectId,
            ref: 'Comment'
        }],
        select: false
    },
})
const User = mongoose.model('User', userSchema)
module.exports = User